package com.ruoyi.helpMove.service.impl;

import java.util.List;

import com.ruoyi.common.weChatRobot.template.QicqMailTemplate;
import com.ruoyi.studentHelp.mapper.SysStudentHelpMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.helpMove.mapper.SysMoveFinishMapper;
import com.ruoyi.helpMove.domain.SysMoveFinish;
import com.ruoyi.helpMove.service.ISysMoveFinishService;

/**
 * 帮扶移交Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-24
 */
@Service
public class SysMoveFinishServiceImpl implements ISysMoveFinishService 
{
    @Autowired
    private SysMoveFinishMapper sysMoveFinishMapper;
    @Autowired
    private SysStudentHelpMapper sysStudentHelpMapper;
    @Autowired
    private QicqMailTemplate qicqMailTemplate;

    /**
     * 查询帮扶移交
     * 
     * @param id 帮扶移交主键
     * @return 帮扶移交
     */
    @Override
    public SysMoveFinish selectSysMoveFinishById(Long id)
    {
        return sysMoveFinishMapper.selectSysMoveFinishById(id);
    }

    /**
     * 查询帮扶移交列表
     * 
     * @param sysMoveFinish 帮扶移交
     * @return 帮扶移交
     */
    @Override
    public List<SysMoveFinish> selectSysMoveFinishList(SysMoveFinish sysMoveFinish)
    {
        return sysMoveFinishMapper.selectSysMoveFinishList(sysMoveFinish);
    }

    /**
     * 新增帮扶移交
     * 
     * @param sysMoveFinish 帮扶移交
     * @return 结果
     */
    @Override
    public int insertSysMoveFinish(SysMoveFinish sysMoveFinish)
    {
//        根据id去修改状态
        sysStudentHelpMapper.updateById(sysMoveFinish.getHelpId());
        return sysMoveFinishMapper.insertSysMoveFinish(sysMoveFinish);
    }

    /**
     * 修改帮扶移交
     * 
     * @param sysMoveFinish 帮扶移交
     * @return 结果
     */
    @Override
    public int updateSysMoveFinish(SysMoveFinish sysMoveFinish)
    {
        return sysMoveFinishMapper.updateSysMoveFinish(sysMoveFinish);
    }

    /**
     * 批量删除帮扶移交
     * 
     * @param ids 需要删除的帮扶移交主键
     * @return 结果
     */
    @Override
    public int deleteSysMoveFinishByIds(Long[] ids)
    {
        return sysMoveFinishMapper.deleteSysMoveFinishByIds(ids);
    }

    /**
     * 删除帮扶移交信息
     * 
     * @param id 帮扶移交主键
     * @return 结果
     */
    @Override
    public int deleteSysMoveFinishById(Long id)
    {
        return sysMoveFinishMapper.deleteSysMoveFinishById(id);
    }

    /**
     * 发送邮件
     * @param sysMoveFinish
     */
    @Override
    public void sentEmail(SysMoveFinish sysMoveFinish) {
        qicqMailTemplate.sendMail("2769970859@qq.com","帮扶移交",sysMoveFinish.getMoveName()+"的帮扶已移交给"+sysMoveFinish.getAccpectName());
    }
}
